# 模拟用户登录

import hashlib

students = []

with open( 'C:\\Users\\wbw\\Desktop\\Whhpython\\homework4\\studentjiami.txt', 'r' ) as f:
    f.readline()
    for line in f.readlines():
        student = line.strip().split()
        students.append( student )

a = 0
while True:

    md5 = hashlib.md5()
    name = input( '请输入学生姓名: ' )
    authority = input( '请输入学生账号: ' )
    password = input( '请输入学生密码: ' )
    md5.update( password.encode( 'utf-8' ) )
    inputstudent = [ name, authority, md5.hexdigest() ]

    if inputstudent in students:
        print( '登录成功!' )
        break
    else:
        a += 1
        print( '登录失败! 还可以尝试 %s 次!' %( 3 - a ) )
        if a >= 3:
            print( '没机会了闸种!' )
            break